#include <bits/stdc++.h>
using namespace std;

bool isprime(int n)
{
    if (n == 1) return false;
    if (n > 1)
    {
        for (int a = 2; a <= sqrt(n); a++)
        {
            if (n % a == 0)
                return false;
        }
    }
    return true;
}

int main()
{
    int a, b;
    cin >> a >> b;
    int count = 0;
    for (int i = max(a, 10); i <= b; i++)
    {
        vector<int> num;
        int x = i;
        while (x)
        {
            num.push_back(x % 10);
            x /= 10;
        }
        for (int j = 0; j < num.size(); j++)
        {
            for (int k = 0; k < num.size(); k++)
            {
                if (k != j && num[j] != 0 && isprime(num[j] * 10 + num[k]))
                {
                    count++;
                    goto th;
                }
            }
        }
    th:
        ;
    }
    cout << count;
}